<ul class="maintabmenu multipletabmenu">
    <li class="current">
        <a href="">Cập nhật danh mục</a>
    </li>    
</ul><!--maintabmenu-->

<div class="content">
    <?php if (isset($category)) { ?>
        <form action="" method="post" class="stdform" id="category-add" novalidate="novalidate">        
            <input type="hidden" name="id" value="<?php echo $category->category_id; ?>"/>
            <p>
                <label>Tên danh mục</label>
                <span class="field"><input type="text" class="mediuminput" id="name" name="name" value="<?php echo $category->category_name; ?>"></span>
            </p>
            <?php $arr = explode('@', $category->category_spot); ?>
            <p>
                <label>Mô tả</label>
                <span class="field">                    
                    <textarea id="description" class="mediuminput" name="description" rows="5" cols="80"><?php echo $category->category_description; ?></textarea>
                </span>
            </p>
            <p>
                <label>Sản phẩm nổi bật 1</label>
                <span class="field">
                    <select name="ddl_related1">
                        <option value="">-- Lựa chọn --</option>
                        <?php foreach ($buildings as $building) { ?>                        
                            <option value="<?php echo $building->building_id; ?>" <?php
                    if (isset($arr[0]) && $arr[0] ==$building->building_id) {
                        echo 'selected=""';
                    }
                            ?>><?php echo $building->building_name; ?></option>
                                <?php } ?>
                    </select>
                </span>
            </p>
            <p>
                <label>Sản phẩm nổi bật 2</label>
                <span class="field">
                    <select name="ddl_related2">
                        <option value="">-- Lựa chọn --</option>
                        <?php foreach ($buildings as $building) { ?>                        
                            <option value="<?php echo $building->building_id; ?>" <?php
                    if (isset($arr[1]) && $arr[1] ==$building->building_id) {
                        echo 'selected=""';
                    }
                            ?>><?php echo $building->building_name; ?></option>
                                <?php } ?>
                    </select>
                </span>
            </p>
            <p>
                <label>Sản phẩm nổi bật 3</label>
                <span class="field">
                    <select name="ddl_related3">
                        <option value="">-- Lựa chọn --</option>
                        <?php foreach ($buildings as $building) { ?>                        
                            <option value="<?php echo $building->building_id; ?>" <?php
                    if (isset($arr[2]) && $arr[2] ==$building->building_id) {
                        echo 'selected=""';
                    }
                            ?>><?php echo $building->building_name; ?></option>
                                <?php } ?>
                    </select>
                </span>
            </p>
            <!--
            <p>
                <label>Sản phẩm nổi bật 1</label>
                <span size="5" multiple="multiple" name="select2">
                    <select id="select_related" name="ddl_related1" multiple="multiple" size="10">
            
            <?php foreach ($buildings as $building) { ?>                        
                                    <option value="<?php echo $building->building_id; ?>" <?php
        if (in_array($building->building_id, $arr)) {
            echo 'selected=""';
        }
                ?>><?php echo $building->building_name; ?></option>
            <?php } ?>
                    </select>                    
                </span>
            </p>
            -->
            <br>

            <p class="stdformbutton">
                <button class="submit radius2">Cập nhật</button>
            </p>
        </form>
    <?php } ?>
</div>
<script type="text/javascript" src="<?php echo base_url(); ?>back-end/js/plugins/jquery-ui-1.8.16.custom.min.js"></script> 
<script type="text/javascript" src="<?php echo base_url(); ?>back-end/js/custom/general.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>back-end/js/plugins/jquery.validate.min.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>back-end/js/custom/form.js"></script>
<!--
<script>
    jQuery("#select_related").change(function () {
        if(jQuery("#select_related option:selected").length > 3) {
            alert('Chỉ được chọn tối đa 3 công trình');
            jQuery('#select_related option:selected').removeAttr('selected');
        }
    });
</script>
-->